package com.yanqu.road.server.manager.yrank;

import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.utils.date.DateHelper;

public class CrossUserYRankCache {
    private int activityId;
    private int groupId;
    private String key;
    private long lastRankTime;

    private RankProto.RankListMsg.Builder rankBuilder = RankProto.RankListMsg.newBuilder();

    public CrossUserYRankCache(int activityId, int groupId, String key) {
        this.activityId = activityId;
        this.groupId = groupId;
        this.key = key;
    }

    public RankProto.RankListMsg.Builder getRankBuilder() {
        return rankBuilder;
    }

    public void setRankBuilder(RankProto.RankListMsg.Builder rankBuilder) {
        this.rankBuilder = rankBuilder;
        this.lastRankTime = DateHelper.getCurrentTime();
    }

    public int getActivityId() {
        return activityId;
    }

    public int getGroupId() {
        return groupId;
    }

    public String getKey() {
        return key;
    }

    public long getLastRankTime() {
        return lastRankTime;
    }

    public void setLastRankTime(long lastRankTime) {
        this.lastRankTime = lastRankTime;
    }

    public boolean isNeedUpdateRank(long checkSecond) {
        long currentTime = DateHelper.getCurrentTime();
        if (currentTime - lastRankTime > checkSecond * DateHelper.SECOND_MILLIONS) {
            return true;
        }
        return false;
    }
}
